package com.qf.first.base.result;

import lombok.Data;

@Data
public class RespVo <T>{
    private int code;
    private String msg;
    private T data;

    public static <T> RespVo<T> success(T data){
        return success(ResultCode.SUCCESS,data);
    }

    public static <T> RespVo<T> success(ResultCode resultCode,T data){
        RespVo respVo= new RespVo();
        respVo.setCode(resultCode.getCode());
        respVo.setMsg(resultCode.getMsg());
        respVo.setData(data);
        return respVo;
    }

    public static <T> RespVo<T> error(){
        return error(ResultCode.ERROR);
    }

    public static <T> RespVo<T> error(ResultCode resultCode){
        RespVo respVo= new RespVo();
        respVo.setCode(resultCode.getCode());
        respVo.setMsg(resultCode.getMsg());
        return respVo;
    }

    public static <T> RespVo<T> error(int code,String msg){
        RespVo respVo= new RespVo();
        respVo.setCode(code);
        respVo.setMsg(msg);
        return respVo;
    }

    public static <T> RespVo<T> unLogin(){
        return unLogin(ResultCode.UN_LOGIN);
    }

    public static <T> RespVo<T> unLogin(ResultCode resultCode){
        RespVo respVo= new RespVo();
        respVo.setCode(resultCode.getCode());
        respVo.setMsg(resultCode.getMsg());
        return respVo;
    }

    public static <T> RespVo<T> accountLoginError(){
        return accountLoginError(ResultCode.UN_LOGIN);
    }

    public static <T> RespVo<T> accountLoginError(ResultCode resultCode){
        RespVo respVo= new RespVo();
        respVo.setCode(resultCode.getCode());
        respVo.setMsg(resultCode.getMsg());
        return respVo;
    }

}
